// 运算时文件
export class Realm {
  constructor() {
    this.golbal = new Map(),
    this.Object = new Map(),
    this.Object.call = function() { // 还包含其他属性 如：execute
    },
    this.Object_prototype = new Map()
  }
}

export class EnvironmentRecord {
  constructor() {
    this.thisValue
    this.variables = new Map()
    this.outer = null
  }
}

export class ExecutionContext { // 包含存储变量的方法以及 prototype 、var
  // LexicalEnvironment：{ a:1, b:2} // 词法环境 lexical就是lexer所依赖的环境
  // global的object 包含三个对象 global对象、Object构造器、Object的原型对象
  constructor(realm, lexicalEnvironment, variableEnvironment) {
    variableEnvironment = variableEnvironment || lexicalEnvironment
    this.lexicalEnvironment = lexicalEnvironment // 这也不会是一个普通的对象 所以有一个EnvironmentRecord
    this.variableEnvironment = variableEnvironment
    this.realm = realm
    // golbal: {},
    // Object: {},
    // Object_prototype: {}
  }
}

export class Reference {
  constructor(object, property) {
    this.object = object
    this.property = property
  }
  get() {
    return this.object[this.property]
  }
  set(value) {
    this.object[this.property] = value
  }
}
